﻿Imports WindowsApplication1.saktiewebservice

Public Class MainForm
    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.MaximumSize = Me.Size
        Me.MinimumSize = Me.Size
        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub

    Private Sub closeAction() Handles Me.FormClosing
        Application.Exit()
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Try
            Dim webser As New Service1SoapClient
            Dim K As New KlantBean
            Dim Kform As New Klant
            K = webser.getKlantbyUsername(txtKlantnaam.Text)
            If (txtKlantnaam.Text.ToLower = "admin") Then
                Kform.tsmVoegProductToe.Visible = True
            End If
            Kform.txtGebruikersnaam.Text = K.Gebruikersnaam
            Kform.txtAchternaam.Text = K.Achternaam
            Kform.txtNaam.Text = K.Naam
            Kform.txtAdres.Text = K.Adres
            Kform.txtOpmerkingen.Text = K.Opmerking
            Kform.mtxtPostcode.Text = K.Postcode
            Kform.txtTelefoon.Text = K.TelefoonNummer
            Kform.txtWoonplaats.Text = K.Woonplaats
            Kform.Id = K.Id
            Kform.StartPosition = FormStartPosition.CenterScreen
            Kform.Show()
            Me.Hide()
        Catch ex As NullReferenceException
            MsgBox("Geen gebruiker gevonden")
        Catch Efe As ServiceModel.EndpointNotFoundException
            MsgBox("Kan geen verbinding maken met de webservice")
        End Try

    End Sub

    Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click
        Dim registerForm As New Klant

        registerForm.userMenu.Visible = False
        registerForm.btnRegister.Visible = True
        registerForm.GroupBox1.Dock = DockStyle.Fill
        registerForm.StartPosition = FormStartPosition.CenterScreen

        registerForm.txtAchternaam.ReadOnly = False
        registerForm.txtNaam.ReadOnly = False
        registerForm.txtAdres.ReadOnly = False
        registerForm.txtOpmerkingen.ReadOnly = False
        registerForm.mtxtPostcode.ReadOnly = False
        registerForm.txtWoonplaats.ReadOnly = False
        registerForm.txtTelefoon.ReadOnly = False
        registerForm.txtGebruikersnaam.ReadOnly = False


        registerForm.Show()
        registerForm.txtGebruikersnaam.Focus()
        Me.Hide()
    End Sub
End Class
